Filter hook 'update_{$meta_type}_metadata_cache'

in WP Core File wp-includes/meta.php at line 1163

View Source

update_{$meta_type}_metadata_cache

Filter Hook
Description
Short-circuits updating the metadata cache of a specific type. The dynamic portion of the hook name, `$meta_type`, refers to the meta object type (post, comment, term, user, or any other type with an associated meta table). Returning a non-null value will effectively short-circuit the function. Possible hook names include: - `update_post_metadata_cache` - `update_comment_metadata_cache` - `update_term_metadata_cache` - `update_user_metadata_cache`

Hook Information

File Location wp-includes/meta.php View on GitHub
Hook Type Filter
Line Number 1163

Hook Parameters

Type Name Description
mixed $check Whether to allow updating the meta cache of the given type.
int[] $object_ids Array of object IDs to update the meta cache for.

Usage Examples

Basic Usage
<?php
// Hook into update_{$meta_type}_metadata_cache
add_filter('update_{$meta_type}_metadata_cache', 'my_custom_filter', 10, 2);

function my_custom_filter($check, $object_ids) {
    // Your custom filtering logic here
    return $check;
}

Source Code Context

wp-includes/meta.php:1163 - How this hook is used in WordPress core
<?php
1158  	 * @since 5.0.0
1159  	 *
1160  	 * @param mixed $check      Whether to allow updating the meta cache of the given type.
1161  	 * @param int[] $object_ids Array of object IDs to update the meta cache for.
1162  	 */
1163  	$check = apply_filters( "update_{$meta_type}_metadata_cache", null, $object_ids );
1164  	if ( null !== $check ) {
1165  		return (bool) $check;
1166  	}
1167  
1168  	$cache_group    = $meta_type . '_meta';

PHP Documentation

<?php
/**
	 * Short-circuits updating the metadata cache of a specific type.
	 *
	 * The dynamic portion of the hook name, `$meta_type`, refers to the meta object type
	 * (post, comment, term, user, or any other type with an associated meta table).
	 * Returning a non-null value will effectively short-circuit the function.
	 *
	 * Possible hook names include:
	 *
	 *  - `update_post_metadata_cache`
	 *  - `update_comment_metadata_cache`
	 *  - `update_term_metadata_cache`
	 *  - `update_user_metadata_cache`
	 *
	 * @since 5.0.0
	 *
	 * @param mixed $check      Whether to allow updating the meta cache of the given type.
	 * @param int[] $object_ids Array of object IDs to update the meta cache for.
	 */
Quick Info
  • Hook Type: Filter
  • Parameters: 2
  • File: wp-includes/meta.php
Related Hooks

Related hooks will be displayed here in future updates.